﻿
using CSharpLibs.Annotations;

namespace System.Text
{
	[Builtin]
	public class StringBuilder : Object
	{
		private Collections.Generic.List<char> contents;

		public StringBuilder()
		{ this.contents = new Collections.Generic.List<char>(); }

		public StringBuilder(String s)
			: this()
		{ this.Append(s); }

		public StringBuilder Append(char[] value, int charCount)
		{
			for(int i = 0; i < charCount; ++i)
				this.contents.Add(value[i]);

			return this;
		}

		public StringBuilder Append(int v)
		{ return this.Append(v.ToString()); }

		public StringBuilder Append(float f)
		{ return this.Append(f.ToString()); }

		public StringBuilder Append(double d)
		{ return this.Append(d.ToString()); }

		public StringBuilder Append(String s)
		{
			for(int i = 0; i < s.Length; ++i)
				this.contents.Add(s[i]);

			return this;
		}

		public StringBuilder Append(object o)
		{ return this.Append(o.ToString()); }

		public StringBuilder AppendLine()
		{ return this.Append("\r\n"); }

		public override string ToString()
		{ return new String(this.contents.ToArray()); }

		public int Length
		{ get { return this.contents.Count; } }
	}
}
